import App from "../../App";
import { GameEvent } from "../../../common/game/event/GameEvent";
import ProtoDispatcher from "../../../common/core/ProtoDispatcher";
import EventDispatcher from "../../../common/core/EventDispatcher";
import { ClientEvent } from "../../event/ClinetEvent";

/** 模型基类 */
export default abstract class BaseMod {

    /** 客户端事件派发器 */
    readonly ed: EventDispatcher<ClientEvent.Def>
    /** 游戏事件派发器 */
    readonly gd: EventDispatcher<GameEvent.Def>
    /** 协议派发器 */
    readonly pd: ProtoDispatcher
    readonly isLocal: Boolean

    constructor() {
        this.ed = App.ed
        this.pd = App.pd
        this.isLocal = App.isLocal
        if (App.isLocal) {
            this.gd = App.localGame.ed
        }
    }

    ready() {
        if (this.isLocal) {
            this.initLocal()
        } else {
            this.initRemote()
        }
    }

    /** 本地初始化 */
    protected abstract initLocal(): void
    /** 联机初始化 */
    protected abstract initRemote(): void

}